//index.js
//获取应用实例
const app = getApp();
const http = require('../../utils/http');


Page({
    data: {

        icon: {
            phone: '../images/icon/phone.png',
            more: '../images/icon/more.png',
            address: '../images/icon/address.png',
        },

    },
    onLoad: function (options) {
        console.log(options);
        let that = this;
        that.setData({
            productId: options.productId
        })
        that.getMerchantList(options.productId);
    },

    //得到商家列表
    getMerchantList: function (productId) {
        const body = {
            productId: productId,
        }
        http._get("/mini/getMerchant", body).then(res => {
            console.log(res);
            if (res.code == 200) {
                this.setData({
                    'merchantList': res.result
                });
            } else {
                wx.showToast({
                    title: res.message,
                    icon: '',
                    duration: 1000,
                    mask: true
                })
                setTimeout(function () {
                    wx.hideToast()
                }, 2000)
            }

        })
    },
    //拨打电话
    handleTel: function (e) {
        console.log(e);
        wx.makePhoneCall({
            phoneNumber: e.currentTarget.dataset.phone
        })
    },

})
